package org.benxiong.iplay.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.benxiong.iplay.model.Conversation;
import org.benxiong.iplay.model.Message;
import org.benxiong.iplay.model.UserProfile;
import org.benxiong.iplay.model.UserThumbnail;

public class GlobalMemoryDataArchive implements DataArchive {

	private List<Conversation>					conversations		= new ArrayList<Conversation>();
	private Map<String, List<Message>>			messagesMap			= new HashMap<String, List<Message>>();
	private Map<String, List<UserThumbnail>>	userThumbnailsMap	= new HashMap<String, List<UserThumbnail>>();
	private Map<String, UserProfile>			userProfilesMap		= new HashMap<String, UserProfile>();

	@Override
	public List<Conversation> getConversations() {
		return this.conversations;
	}

	@Override
	public List<Message> getMessages(String sender) {
		return messagesMap.get(sender);
	}

	@Override
	public List<UserThumbnail> getUserThumbnails(String key) {
		return userThumbnailsMap.get(key);
	}

	public void setConversations(List<Conversation> conversations) {
		this.conversations = conversations;
	}

	public Map<String, List<Message>> getMessagesMap() {
		return messagesMap;
	}

	public void setMessagesMap(Map<String, List<Message>> messagesMap) {
		this.messagesMap = messagesMap;
	}

	public Map<String, List<UserThumbnail>> getUserThumbnailsMap() {
		return userThumbnailsMap;
	}

	public void setUserThumbnailsMap(Map<String, List<UserThumbnail>> userThumbnailsMap) {
		this.userThumbnailsMap = userThumbnailsMap;
	}

	public Map<String, UserProfile> getUserProfilesMap() {
		return userProfilesMap;
	}

	public void setUserProfilesMap(Map<String, UserProfile> userProfilesMap) {
		this.userProfilesMap = userProfilesMap;
	}

	@Override
	public UserProfile getUserProfile(String username) {
		return userProfilesMap.get(username);
	}

	@Override
	public void reset() {
		this.conversations.clear();
		this.messagesMap.clear();
		this.userProfilesMap.clear();
		this.userThumbnailsMap.clear();
	}

}
